<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/meringerTemplate.xhtml">

	<ui:define name="content">
		<h:form id="form">
			<p:growl id="messages" showDetail="true" />

			<p:dataTable var="user" value="#{userAdminBean.allUsers}"
				id="userList" editable="true">

				<f:facet name="header">  
            		User Administration  
        		</f:facet>

				<p:ajax event="rowEdit" listener="#{userAdminBean.onEdit}"
					update=":form:messages" />
				<p:ajax event="rowEditCancel" listener="#{userAdminBean.onCancel}"
					update=":form:messages" />

				<p:column id="userName" headerText="Name" style="width:20%">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{user.username}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText id="userNameInput" value="#{user.username}"
								style="width:100%" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column id="userActivity" headerText="Is active" style="width:20%">
					<p:cellEditor>
						<f:facet name="output">
							<p:selectBooleanCheckbox value="#{user.isActive}" disabled="true">
							</p:selectBooleanCheckbox>
						</f:facet>
						<f:facet name="input">
							<p:selectBooleanCheckbox value="#{user.isActive}">
							</p:selectBooleanCheckbox>
						</f:facet>
					</p:cellEditor>
				</p:column>
				
				<p:column id="userGroups" headerText="Is User"
					style="width:20%">
					<p:cellEditor>
						<f:facet name="output">
							<p:selectBooleanCheckbox value="#{user.isUser}" disabled="true">
							</p:selectBooleanCheckbox>
						</f:facet>
						<f:facet name="input">
							<p:selectBooleanCheckbox value="#{user.isUser}">
							</p:selectBooleanCheckbox>
						</f:facet>
					</p:cellEditor>
				</p:column>
				
				<p:column id="userRoles" headerText="Is Administrator"
					style="width:20%">
					<p:cellEditor>
						<f:facet name="output">
							<p:selectBooleanCheckbox value="#{user.isAdmin}" disabled="true">
							</p:selectBooleanCheckbox>
						</f:facet>
						<f:facet name="input">
							<p:selectBooleanCheckbox value="#{user.isAdmin}">
							</p:selectBooleanCheckbox>
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column style="width:6%">
					<p:rowEditor />
				</p:column>

			</p:dataTable>

		</h:form>
	</ui:define>
</ui:composition>

</html>
